#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>

int main()
{
    /*打开文件*/
    const char * filename = "./record.txt";
    int fd = open(filename,O_RDWR | O_CREAT,0644);
    if(fd == -1)
    {
        perror("open error:");
        exit(-1);
    }
    printf("fd = %d\n",fd);

    const char * buffer = "hello world!";
    int writeBytes = write(fd,(void *)buffer,strlen(buffer));
    printf("writeBytes = %d\n",writeBytes);
    close(fd);
    
    return 0;
}